<template>
  <el-header class="wall-box">
    <el-row class="header-box">
      <div class="ui-flex logo-box">
        <div class="ui-flex">
          <h3 class="text">业务中台</h3>
          <i class="el-icon-s-fold anticon"
            v-if="device"
            @click="toggle"></i>
          <i class="el-icon-s-unfold anticon"
            v-else
            @click="toggle"></i>
        </div>

        <div class="menu-box"
          v-if="false">
          <ul>
            <li>用户管理</li>
            <!-- <li>用户管理</li>
            <li>用户管理</li>
            <li>用户管理</li> -->
          </ul>
        </div>
      </div>

      <div class="user-box">
        <el-dropdown @command="handleCommand">
          <span class="user-nav-box">
            <img :src="userImg"
              class="layui-circle"
              width="35"
              height="35" />
            <span class="cite">{{ userName }}</span>
          </span>
          <el-dropdown-menu slot="dropdown">
            <!-- <el-dropdown-item>修改密码</el-dropdown-item> -->
            <el-dropdown-item command="a">退出</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </div>
    </el-row>
  </el-header>
</template>

<script>
import cookie from "js-cookie";
import { mapActions } from "vuex";
import {
  Row,
  Header,
  Dropdown,
  DropdownMenu,
  DropdownItem,
  Icon,
} from "element-ui";
export default {
  name: "indexHeader",
  components: {
    [Header.name]: Header,
    [Dropdown.name]: Dropdown,
    [DropdownMenu.name]: DropdownMenu,
    [DropdownItem.name]: DropdownItem,
    [Row.name]: Row,
  },
  data() {
    return {
      userImg: require("../../assets/img/face.jpg"),
      userName: this.$getCookie("name"),
      device: true,
    };
  },
  methods: {
    ...mapActions(['setSidebar']),
    handleCommand(command) {
      var that = this;
      if (command == "a") {
        localStorage.setItem("token", "");
        setTimeout(() => {
          that.$router.push({ path: "/login" });
        }, 1000);
      }
    },
    toggle() {
      this.device = !this.device;
      this.setSidebar(this.device);
    },
  },
};
</script>

<style scoped>
.wall-box {
  background: #23262e;
  width: 100%;
  min-height: 55px;
  z-index: 999;
}

.header-box {
  height: 100%;
}
.logo-box {
  height: 60px;
  float: left;
}

.logo-box img {
  display: inline-block;
  height: 100%;
}

.logo-box .text {
  display: block;
  color: #f5f5f5;
  width: 180px;
}

/* 用户 */
.user-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 60px;
  float: right;
}

.user-nav-box {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0 20px;
  color: #fff;
  transition: all 0.3s;
  -webkit-transition: all 0.3s;
  height: 50px;
  line-height: 50px;
}
.user-nav-box img {
  border-radius: 100%;
}
.user-nav-box .cite {
  display: block;
  padding: 0 5px;
  font-size: 14px;
}

/* 菜单 */
.menu-box {
  display: block;
}

.menu-box ul {
  list-style-type: none;
  padding: 0px;
  margin: 0px;
}

.anticon {
  display: inline-block;
  color: inherit;
  font-style: normal;
  line-height: 0;
  text-align: center;
  text-transform: none;
  vertical-align: -0.125em;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  font-size: 30px;
  cursor: pointer;
}
/* .menu-box ul li{
  display: block;
  padding: 0 10px;
} */
</style>